import './assets/main.css'

import { createApp } from 'vue'
import { createPinia } from 'pinia'

import App from './App.vue'
import router from './router'

// 添加Element Plus导入
import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
import axios from 'axios'  // 导入axios

// 移除baseURL，避免重复
// axios.defaults.baseURL = '/api'

// 添加请求拦截器
axios.interceptors.request.use(
    (config) => {
        const token = localStorage.getItem('token')
        if (token) {
            config.headers.Authorization = `Bearer ${token}`
        }
        return config
    },
    (error) => Promise.reject(error)
)

const app = createApp(App)

app.use(createPinia())
app.use(router)
// 使用Element Plus
app.use(ElementPlus)

app.mount('#app')
